package graphesTOTEST;

import static org.junit.Assert.*;
import org.junit.Test;

/**
 * 
 * @author simon duval
 * @author youssef lahrizi
 *
 * Test de l'algorithme de construction de graphes isomorphiques 
 */

public class IsomorphismeTest {

	Graphe g0,g1;
	Isomorphisme i1;
	
	@Test
	public void testBuidIsomorphisme() {
		// test constructeurs graphes vide
		g0 = new Graphe();
		g1 = new Graphe();
		i1 = new Isomorphisme(g0,g1);
		assertTrue(i1.buidIsomorphisme());
		
		
		int N = Graphe.ALPHA_NOTDEF;
		int [][] matg0vide = { {  } };
		int [][] matg1vide = { {  } };
		g0 = new Graphe(matg0vide);
		g1 = new Graphe(matg1vide);
		i1 = new Isomorphisme(g0,g1);
		assertTrue(i1.buidIsomorphisme());
		
		g0 = new Graphe(2);
		g1 = new Graphe(2);
		i1 = new Isomorphisme(g0,g1);
		assertTrue(i1.buidIsomorphisme());
		
		// graphes isomorphiques
		int [][] matg0 = { {0,1,0},
						   {1,0,1},
						   {0,1,0}  };
		int [][] matg1 = { {0,0,1},
				   		   {0,0,1},
				           {1,1,0}  };
		g0 = new Graphe(matg0);
		g1 = new Graphe(matg1);
		i1 = new Isomorphisme(g0,g1);
		assertTrue(i1.buidIsomorphisme());
		
		// sous graphe isomorphique
		int [][] matg2 = {  {0,0,0},
							{0,0,1},
							{0,1,0}  };
		int [][] matg3 = {  {0,0,1},
							{0,0,1},
							{1,1,0}  };
		g0 = new Graphe(matg2);
		g1 = new Graphe(matg3);
		i1 = new Isomorphisme(g0,g1);
		assertTrue(i1.buidIsomorphisme());
		
		// graphes isomorphique
		int [][] matg4 = {  {0,1,0,1},
							{1,0,0,1},
							{0,1,0,0},
							{0,1,0,0}  };
		int [][] matg5 = {  {0,1,0,0},
							{1,0,1,0},
							{0,1,0,1},
							{0,0,1,0}  };
		
		g0 = new Graphe(matg4);
		g1 = new Graphe(matg5);
		i1 = new Isomorphisme(g0,g1);
		assertTrue(i1.buidIsomorphisme());
		
		// graphe non isomorphique
		int [][] matg6 = { /*         1   2   3   4   5   6   7*/
				   /* 1 */ {  N,  N,  N,  N,  1,  1,  N},
				   /* 2 */ {  N,  N,  1,  1,  1,  1,  N},
				   /* 3 */ {  N,  1,  N,  N,  N,  N,  N},
				   /* 4 */ {  N,  1,  N,  N,  N,  1,  N},
				   /* 5 */ {  1,  1,  N,  N,  N,  N,  N},
				   /* 6 */ {  1,  1,  N,  1,  N,  N,  N},
				   /* 7 */ {  N,  N,  N,  N,  N,  N,  N}, };
				   
		int [][] matg7 = { /*         1   2   3   4   5   6 */
				   /* 1 */ {  N,  1,  N,  N,  1,  1},
				   /* 2 */ {  1,  N,  N,  N,  1,  N},
				   /* 3 */ {  N,  N,  N,  N,  1,  1},
				   /* 4 */ {  N,  N,  N,  N,  1,  N},
				   /* 5 */ {  1,  1,  1,  1,  N,  N},
				   /* 6 */ {  1,  N,  1,  N,  N,  N}};
		g0 = new Graphe(matg6);
		g1 = new Graphe(matg7);
		i1 = new Isomorphisme(g0,g1);
		assertFalse(i1.buidIsomorphisme());	
	}
}
